import { Injectable } from '@nestjs/common';
import {InjectRepository} from '@nestjs/typeorm'
import {Repository} from 'typeorm'
import {PartEntity} from './part.entity'

@Injectable()
export class PartService {
    constructor(
        @InjectRepository(PartEntity)
        private readonly partRepository: Repository<PartEntity>
    ){}
    async create ():Promise<string> {
        let part = new PartEntity()
        part.bookId = 1
        part.content = '*这是习近平在十八届中央政治局常委同中外记者见面时讲话的主要部分。'
        part.markId = ''
        part.annotationCount = 33
        return this.partRepository.save(part).then(res => {
            return '新增成功'
        })
    }

    async findList (params): Promise<PartEntity[]> {
        return this.partRepository.find({where: {bookId: params.bookId, chapterId: params.chapterId}})
    }
}
